﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace SomeGame.Actors.Components {

	public class Rotation : ActorComponent {

		private readonly float RotationSpeed; // Per second. Example: 2*pi (full rotation).
		private readonly bool RotatesClockwise;
	    private Appearance Appearance;

		public Rotation(Appearance appearance, float rotationSpeed, bool rotatesClockwise = true) {
			RotationSpeed = rotationSpeed;
			RotatesClockwise = rotatesClockwise;
		}

		public override void Update(GameTime gameTime, bool parallax) {
			if (RotatesClockwise) {
				Appearance.Rotation += (float) (gameTime.ElapsedGameTime.TotalSeconds*RotationSpeed);
			} else {
				Appearance.Rotation -= (float) (gameTime.ElapsedGameTime.TotalSeconds*RotationSpeed);
			}
			if (Appearance.Rotation > MathHelper.TwoPi) {
				Appearance.Rotation -= MathHelper.TwoPi;
			}
		}

	}

}